# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
import os
import sys
import time
import serial
import pandas as pd

# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    tick = time.time()
    portName = sys.argv[2]
    fileName = sys.argv[3]
    # 输入并解析文件
    data = pd.read_csv(sys.path[0] + '\\' + fileName, header=None, dtype='int8').values  # 读取首列到ndarray

    # 发送字节流
    com = serial.Serial(portName, 115200, timeout=1)
    txLen = com.write(data.tobytes())
    print("txFile %dB in %.1fms" % (txLen, (time.time() - tick) * 1000))
    exit(0)
